<script type="text/javascript">
    $(document).ready(function(){
        $('#save').click(function() {
            var id='';
            var order = '';
            var i = 0;
            var data ='';
            $('.order').each(function(){
                i  = i +1;
                id = '&id'+i+'='+$(this).attr('id');
                order = '&order'+i+'='+$(this).val();
                data = data+id+order;
            });
            //alert(data);
            $.ajax({
                url: "<?php echo base_url();?>/mod_artice/admin_artice/xulyajax",
                type: "POST",
                cache: false,
                data: data,
                success: function(html){
                    $(".test").html(html);
                }
            });
        });
    });
        
</script>
<div class="test"></div>
<div class="artice">
<a href="<?php echo base_url().'backend/admin/artice/add'?>">Thêm bài viết</a>
<h3>Danh mục</h3>
<ul>
<?php foreach($danhmuc as $dm){
    echo '<li><a href="'.base_url().'backend/admin/artice/iddm-'.$dm->id.'">'.$dm->title.'</a></li>';
}
?>
</ul>
<table style="width:100%;">
<tr class="title">
<td class="center" style="width:50px">ID</td>
<td style="">Tiêu đề</td>
<td class="center" style="width:100px">Sắp xếp/<img src="<?php echo base_url().'template/images/h3-maincontent.png' ; ?>" style="cursor:pointer" title="Save" alt="save" id="save" /></td>
<td class="center" style="width:100px">Danh mục</td>
<td class="center" style="width:100px">Modify</td>
</tr>
<?php 
    if(!empty($artice)){
        $i = 0;
        foreach($artice as $ar){
            if($i%2 == 0) $row = 'odd';
            else $row = 'even';
            $i ++;
            echo '<tr class="'.$row.'">';
                echo '<td class="center">'.$ar->id.'</td>';
                echo '<td>'.$ar->title.'</td>';
                echo '<td class="center"><input type="text" id="'.$ar->id.'" class="order" value="'.$ar->order.'" /></td>';
                echo '<td class="center">';
                foreach($danhmuc as $dm){
                    if ($dm->id == $ar->iddanhmuc)
                        echo $dm->title;
                }
                echo '</td>';
                echo '<td class="center">';
                    echo '<a href="'.base_url().'backend/admin/artice/edit-'.$ar->id.'"> sửa </a>';
                    echo '<a href="'.base_url().'backend/admin/artice/dele-'.$ar->id.'"> xóa </a>';
                echo '</td>';
            echo '</tr>';
        }
    }else{
        echo '<tr><td colspan="4">không có dữ liệu</td></tr>';
    }
?>
</table>
</div>
<div class="phantrang"><?php echo $this->pagination->create_links();?></div>